package com.manbu.live.id.generate.provider;

import com.manbu.live.id.generate.provider.service.IdGenerateService;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**
 * @author hanWang
 * @Title:
 * @Package
 * @Description:
 * @date 2024/1/2412:16 PM
 */

@SpringBootApplication
@EnableDubbo
@EnableDiscoveryClient
public class IdGenerateProvider {

    /**
     *    CommandLineRunner 是测试启动类 可以测试接口使用
     */
    @Resource
    private IdGenerateService idGenerateService;
    public static void main(String[] args) {
        // 传统启动springboot项目方式 args 传参数
        // SpringApplication.run(UserProviderApplication.class,args);
        // 可以设置参数
        SpringApplication springApplication = new SpringApplication(IdGenerateProvider.class);
        /**
         * dubbo启动纯是netty的应用进程 用不到tomcat的就是纯粹的spring容器
         */
        springApplication.setWebApplicationType(WebApplicationType.NONE);
        springApplication.run(args);
        System.out.println("==================mb-live-id-generate-provider=================================");

    }

//    @Override
//    public void run(String... args) throws Exception {
//        for (int i =0;i< 1000;i++){
//
//            Long id = idGenerateService.geSeqId(1);
//            System.out.println("策略生成的id为:==="+id);
//        }
//
//    }
}
